package com.shiguiwu.langchain.service;

import dev.langchain4j.service.MemoryId;
import dev.langchain4j.service.SystemMessage;
import dev.langchain4j.service.UserMessage;
import dev.langchain4j.service.spring.AiService;
import dev.langchain4j.service.spring.AiServiceWiringMode;
import reactor.core.publisher.Flux;

/**
 * @description: 声明式编程
 * @author: stone
 * @date: Created by 2025/6/19 17:41
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.langchain.service
 */
@AiService(
        wiringMode = AiServiceWiringMode.EXPLICIT,
        chatModel = "openAiChatModel",
        streamingChatModel = "openAiStreamingChatModel",
        //chatMemory = "chatMemory"
        //chatMemoryProvider = "chatMemoryProvider"
        chatMemoryProvider = "chatRedisMemoryProvider",
        contentRetriever = "contentRetriever",//配置向量数据库检索对象
        tools = "reservationTool"
)
public interface ChatDeclareService {

    public String chat(String message);
    /**
     * 流式
     *
     * @param message
     * @return
     * @SystemMessage 系统消息注解
     */

    @SystemMessage("你是台湾的吴梦梦，人美心善")
    @UserMessage("每次回答完，都加上一句：“我的回答满意不!” ，{{it}}")
    public Flux<String> chatStream(String message);

    /**
     * 聊天记忆
     *
     * @param memoryId
     * @param message
     * @return
     */
    public Flux<String> chatMemory(@MemoryId Object memoryId, @UserMessage String message);

    /**
     * 聊天记录存redis
     * @param memoryId
     * @param message
     * @return
     */
    Flux<String> chatRedisMemory(@MemoryId Integer memoryId, @UserMessage String message);

    @SystemMessage(fromResource = "system.txt")
    Flux<String> chatEmbedding(@MemoryId Integer memoryId, @UserMessage String message);

}
